﻿using B.Z.BasicData.Domain.Entity.Excused;
using B.Z.BasicData.ErrorCode;
using B.Z.BasicData.Infrastructure;
using MediatR;

namespace B.Z.BasicData.API.Read.Application.Excused
{
    public class DepartmentQueryCommandHandler : IRequestHandler<DepartmentQueryCommand, APIResult<List<T_Department>>>
    {
        private readonly IBaseRepository<T_Department> departRepository;

        public DepartmentQueryCommandHandler(IBaseRepository<T_Department> departRepository)
        {
            this.departRepository = departRepository;
        }

        public Task<APIResult<List<T_Department>>> Handle(DepartmentQueryCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<T_Department>> result = new APIResult<List<T_Department>>();
            result.Code = APIEnum.ok;
            result.Message = "获取成功";
            var list = departRepository.GetAll().ToList();
            result.Data = list;
            return Task.FromResult(result);
        }
    }
}
